home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_gimp.idb / usr / freeware / share / gimp / scripts / waves-anim.scm.z / waves-anim.scm
Encoding:
GIMP Script-Fu Script  |  1999-07-21  |  2.9 KB  |  125 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; This program is free software; you can redistribute it and/or modify
  4. ; it under the terms of the GNU General Public License as published by
  5. ; the Free Software Foundation; either version 2 of the License, or
  6. ; (at your option) any later version.  
  7. ; This program is distributed in the hope that it will be useful,
  8. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10. ; GNU General Public License for more details.
  11. ; You should have received a copy of the GNU General Public License
  12. ; along with this program; if not, write to the Free Software
  13. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. ;
  15. ;
  16. ; waves-anim.scm   version 1.01   12/13/97
  17. ;
  18. ; CHANGE-LOG:
  19. ; 1.00 - initial release
  20. ; 1.01 - some code cleanup, no real changes
  21. ;
  22. ; Copyright (C) 1997 Sven Neumann (neumanns@uni-duesseldorf.de)
  23. ;  
  24. ; Makes a copy of your image and creates an animation of the active layer
  25. ; as if a stone was thrown into the image. The animation may be saved with 
  26. ; the gif-plug-in. 
  27.  
  28. (define (script-fu-waves-anim img 
  29.                   drawable 
  30.                   amplitude 
  31.                   wavelength 
  32.                   num-frames
  33.                   invert)
  34.   (let* ((amplitude (max 0 amplitude))
  35.      (wavelength (max 0 wavelength))
  36.      (num-frames (max 1 num-frames))
  37.      (remaining-frames num-frames)
  38.      (phase 0)
  39.      (phaseshift (/ 360 num-frames))
  40.          (image (car (gimp-channel-ops-duplicate img)))
  41.      (source-layer (car (gimp-image-get-active-layer image))))
  42.    
  43.   (gimp-image-disable-undo image)
  44.  
  45.   (if (= invert TRUE)
  46.       (set! phaseshift (- 0 phaseshift)))
  47.   
  48.   (while (> remaining-frames 1)
  49.      (let* ((waves-layer (car (gimp-layer-copy source-layer TRUE)))
  50.         (layer-name (string-append "Frame " 
  51.                        (number->string
  52.                         (- (+ num-frames 2) 
  53.                            remaining-frames) 10))))
  54.          (gimp-layer-set-preserve-trans waves-layer FALSE)
  55.      (gimp-image-add-layer image waves-layer -1)
  56.      (gimp-layer-set-name waves-layer layer-name)
  57.      
  58.      (plug-in-waves 1 
  59.             image 
  60.             waves-layer
  61.             amplitude 
  62.             phase 
  63.             wavelength 
  64.             0 
  65.             FALSE)
  66.       
  67.      (set! remaining-frames (- remaining-frames 1))
  68.      (set! phase (- phase phaseshift))))
  69.  
  70.   (gimp-layer-set-name source-layer "Frame 1")
  71.   (plug-in-waves 1 
  72.          image 
  73.          source-layer
  74.          amplitude 
  75.          phase 
  76.          wavelength 
  77.          0 
  78.          FALSE)
  79.  
  80.   (gimp-image-enable-undo image)
  81.   (gimp-display-new image)))
  82.  
  83. (script-fu-register "script-fu-waves-anim" 
  84.             "<Image>/Script-Fu/Animators/Waves"
  85.             "Animate an image like a stone's been thrown into it"
  86.             "Sven Neumann (neumanns@uni-duesseldorf.de)"
  87.             "Sven Neumann"
  88.             "12/13/1997"
  89.             "RGB RGBA GRAY GRAYA"
  90.             SF-IMAGE "Image" 0
  91.             SF-DRAWABLE "Drawable" 0
  92.             SF-VALUE "Amplitude" "10"
  93.             SF-VALUE "Wavelength" "10" 
  94.             SF-VALUE "Number of Frames" "6"
  95.             SF-TOGGLE "Invert direction" FALSE)
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.